(define (left-branch tree)
  (car tree))

(define (left-branch tree)
  (car (cdr tree)))

(define (branch-length branch)
  (car branch))

(define (branch-structure branch)
  (car (cdr branch)))

(define (branch-weigh branch)
  (if (pair? branch)
    (total-weight (branch-structure branch))
    (branch-structure branch)))

(define (total-weight tree)
  (let ((left (left-branch tree))
        (right (right-branch tree))))
  (+ (branch-weigh left) (branch-weigh right)))

(define (is-balance? tree)
  (let ((left (left-branch tree))
        (right (right-branch tree))))
  (if (and (= (* (branch-length left) (branch-weigh left))
              (* (branch-length right) (branch-weigh right)))
           (is-balance? left)
           (is-balance? right))
    #t
    #f))
